[XEN] Add a warning about changeable size of shared_info structure.
authorkaf24@localhost.localdomain <kaf24@localhost.localdomain>
Sat, 12 Aug 2006 15:18:08 +0000 (16:18 +0100)
committerkaf24@localhost.localdomain <kaf24@localhost.localdomain>
Sat, 12 Aug 2006 15:18:08 +0000 (16:18 +0100)
sizeof(shared_info_t) can change even in compatible hypervisor
versions.
Add a clear warning about this, and fix the few places relying on it.
In addition, add some padding to arch_shared_info, to allow future
additions to the structure without breaking known offsets of members
following it in the shared info.

Signed-off-by: John Levon <john.levon@sun.com>
tools/libxc/xc_hvm_build.c
tools/libxc/xc_linux_build.c
tools/libxc/xc_linux_restore.c
xen/include/public/arch-ia64.h
xen/include/public/arch-powerpc.h
xen/include/public/arch-x86_32.h
xen/include/public/arch-x86_64.h
xen/include/public/xen.h

index d374631913d7e0faa8e9a6a6eb665f9a0dbe8974..3aebbbe8ef5c45456d4d1f90651034e47f9c78d6 100644 (file)
@@ -303,7 +303,7 @@ static int setup_guest(int xc_handle,
               xc_handle, dom, PAGE_SIZE, PROT_READ | PROT_WRITE,
               shared_info_frame)) == 0 )
         goto error_out;
-    memset(shared_info, 0, sizeof(shared_info_t));
+    memset(shared_info, 0, PAGE_SIZE);
     /* Mask all upcalls... */
     for ( i = 0; i < MAX_VIRT_CPUS; i++ )
         shared_info->vcpu_info[i].evtchn_upcall_mask = 1;
index 9e7d39e34afb9ddcdb408277597a60fcdd3c35ed..f3649d4314e71227d9642473a98fb46237dc4550 100644 (file)
@@ -593,7 +593,7 @@ static int setup_guest(int xc_handle,
         xc_handle, dom, PAGE_SIZE, PROT_READ|PROT_WRITE, shared_info_frame);
     printf("shared_info = %p, err=%s frame=%lx\n",
            shared_info, strerror (errno), shared_info_frame);
-    //memset(shared_info, 0, sizeof(shared_info_t));
+    //memset(shared_info, 0, PAGE_SIZE);
     /* Mask all upcalls... */
     for ( i = 0; i < MAX_VIRT_CPUS; i++ )
         shared_info->vcpu_info[i].evtchn_upcall_mask = 1;
@@ -1064,7 +1064,7 @@ static int setup_guest(int xc_handle,
     /* shared_info page starts its life empty. */
     shared_info = xc_map_foreign_range(
         xc_handle, dom, PAGE_SIZE, PROT_READ|PROT_WRITE, shared_info_frame);
-    memset(shared_info, 0, sizeof(shared_info_t));
+    memset(shared_info, 0, PAGE_SIZE);
     /* Mask all upcalls... */
     for ( i = 0; i < MAX_VIRT_CPUS; i++ )
         shared_info->vcpu_info[i].evtchn_upcall_mask = 1;
index ad1d916d55e92f5de8f0a18c7cfcbee7da57524c..4f944d6a320415ac1dab094ca47182fcb94e4f4f 100644 (file)
@@ -737,7 +737,7 @@ int xc_linux_restore(int xc_handle, int io_fd,
     /* Copy saved contents of shared-info page. No checking needed. */
     page = xc_map_foreign_range(
         xc_handle, dom, PAGE_SIZE, PROT_WRITE, shared_info_frame);
-    memcpy(page, shared_info, sizeof(shared_info_t));
+    memcpy(page, shared_info, PAGE_SIZE);
     munmap(page, PAGE_SIZE);
 
     /* Uncanonicalise the pfn-to-mfn table frame-number list. */
index ce71c736c82a66f15e83215a75350efccc7d66da..23cdf015e8f9f43dbb590e099591a02e23dc3a3b 100644 (file)
@@ -297,6 +297,8 @@ struct arch_shared_info {
 
     /* Interrupt vector for event channel.  */
     int evtchn_vector;
+
+    uint64_t pad[32];
 };
 typedef struct arch_shared_info arch_shared_info_t;
 
index 17b6bbd257104a41b6ed0f470ec8f63bfc1387e4..139b945e75da88d2b9d6eb94a13763da2462693b 100644 (file)
@@ -107,6 +107,7 @@ typedef struct vcpu_guest_context vcpu_guest_context_t;
 DEFINE_XEN_GUEST_HANDLE(vcpu_guest_context_t);
 
 struct arch_shared_info {
+    uint64_t pad[32];
 };
 
 struct arch_vcpu_info {
index 096ab9736d5e0ba075e7b8dc80566fbfe6608734..9eece83813b416b99885ee3c906a92589f81c9c4 100644 (file)
@@ -191,6 +191,7 @@ struct arch_shared_info {
     /* Frame containing list of mfns containing list of mfns containing p2m. */
     xen_pfn_t     pfn_to_mfn_frame_list_list;
     unsigned long nmi_reason;
+    uint64_t pad[32];
 };
 typedef struct arch_shared_info arch_shared_info_t;
 
index 715a538f04d15d32d3c9cfb19bea1db543d9503f..a92387f12544d7bd4f091c82b5f5cdfa1da59075 100644 (file)
@@ -261,6 +261,7 @@ struct arch_shared_info {
     /* Frame containing list of mfns containing list of mfns containing p2m. */
     xen_pfn_t     pfn_to_mfn_frame_list_list;
     unsigned long nmi_reason;
+    uint64_t pad[32];
 };
 typedef struct arch_shared_info arch_shared_info_t;
 
index 57d5895b9eef976b73dba0adc5230f29a87368db..6cc0ee9c81700557c5348d2c6c05dd6d4aebe3c6 100644 (file)
@@ -376,7 +376,11 @@ typedef struct vcpu_info vcpu_info_t;
 
 /*
  * Xen/kernel shared data -- pointer provided in start_info.
- * NB. We expect that this struct is smaller than a page.
+ *
+ * This structure is defined to be both smaller than a page, and the
+ * only data on the shared page, but may vary in actual size even within
+ * compatible Xen versions; guests should not rely on the size
+ * of this structure remaining constant.
  */
 struct shared_info {
     struct vcpu_info vcpu_info[MAX_VIRT_CPUS];